package com.softeem.service.impl;

import com.softeem.dao.StudentDao;
import com.softeem.dao.impl.StudentDaoImpl;
import com.softeem.entity.Course;
import com.softeem.entity.Student;
import com.softeem.service.StudentService;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class StudentServiceImpl implements StudentService {

    private StudentDao dao = new StudentDaoImpl();

    @Override
    public Integer login(String username, String password) throws SQLException {
        return dao.login(username,password);
    }

    @Override
    public List<Student> findAll() throws SQLException {
        return dao.findAll();
    }


    public Integer total(Student student) throws SQLException {
        return dao.total(student);
    }

    @Override
    public List<Student> findPages(String pagNo) throws SQLException {
        return dao.findPages(pagNo);
    }

    @Override
    public int addStu(Student stu) throws SQLException {
        return dao.addStu(stu);
    }

    @Override
    public Integer updateStu(Student stu) throws SQLException {
        return dao.updateStu(stu);
    }

    @Override
    public Student findOne(String stuid) throws SQLException {
        return dao.findOne(stuid);
    }

    @Override
    public Integer delete(String stuid) throws SQLException {
        return dao.delete(stuid);
    }


    public List<Student> findByCase(Student stu) throws SQLException {
        //总页数
        return dao.findByCase(stu);
//        Integer total = total(stu);
//        //当前展示的信息
//        List<Student> list = dao.findByCase(stu);
//        //当前页
//        Integer page = Integer.valueOf(pageNo);
//
//        Map map = new HashMap();
//        map.put("total", total);
//        map.put("list", list);
//        map.put("page", page);
//
//        return map;
    }


//    public Map findByCase(Student stu) throws SQLException {
//        Integer total = total(stu);
//        List<Student> list = dao.findByCase(stu);
//        Map map = new HashMap();
//        map.put("total",total);
//        map.put("list",list);
//        return map;
//    }

    @Override
    public List<Course> findCourse() throws SQLException {
        return dao.findCourse();
    }

    @Override
    public int addCourse(Course cou) throws SQLException {
        return dao.addCourse(cou);
    }

    @Override
    public int addEle(List<Course> list1, String fileName) throws SQLException {
        return dao.addEle(list1,fileName);
    }

    @Override
    public void save(List list) throws SQLException {
        dao.save(list);
    }

    @Override
    public Course findCouByCno(String cno) throws SQLException {
        return dao.findCouByCno(cno);
    }

    @Override
    public Integer updateCou(Course cou) throws SQLException {
        return dao.updateCou(cou);
    }

    @Override
    public void addFile(String[] split) throws SQLException {
        dao.addFile(split);
    }
}
